#ifndef TYPE_ROUTINGTABLE_H_
#define TYPE_ROUTINGTABLE_H_
#include <time.h>
#include "bloom_filter.h"
#include "typecast_params.h"

// Local IP Address
//u_int32_t local_ip_addr;

// Multicast Group and Neighbor nodes declaration
typedef struct _multicast_group_node multicast_group_node;

struct _multicast_neighbor_node
{
    // multicast_group_node * up;               // Pointer to the multicast group this belongs to
    u_int32_t multicast_neighbor_addr;          // Neighbor IP address
    bloom_filter_t FBF;                         // FBF received from the neighbor
    bloom_filter_t ABF;                         // Advertised bloom filter to the neighbor
    time_t expire;                              // Timeout value for the entry
    struct _multicast_neighbor_node* next;      // Link to next neighbor node
};
    
typedef struct _multicast_neighbor_node multicast_neighbor_node;

struct _multicast_group_node
{
        multicast_neighbor_node* neighborHead;      // Neighbor list head of multicast group
        u_int32_t multicast_group_addr;             // Multicast group address
        bloom_filter_t LBF;                         // Local Bloom Filter
        struct _multicast_group_node* next;         // Link to next node
};


// Routing Table manipulation
multicast_group_node* GetRoutingTable();
multicast_group_node* FindMulticastGroup(u_int32_t multicast_group_addr);
multicast_group_node* InsertMulticastGroup(u_int32_t multicast_group_addr, bloom_filter_t LBF);
multicast_neighbor_node* FindMulticastNeighbor(u_int32_t multicast_group_addr, u_int32_t multicast_neighbor_addr);
multicast_neighbor_node* InsertMulticastNeighbor(u_int32_t multicast_group_addr, u_int32_t multicast_neighbor_addr, bloom_filter_t FBF);
int UpdateMulticastNeighbor(multicast_neighbor_node * neighbor, bloom_filter_t FBF); 

void UpdateABFs();
void DumpTypeCastRoutingTable(int fd); 

#endif /*TYPE_ROUTINGTABLE_H_*/
